package com.xbongbong.lfasr.model;

import lombok.Getter;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

@Getter
public enum LfasrType {
    LFASR_STANDARD_RECORDED_AUDIO("标准版-已录制音频", "wav,flac,opus,mp3,m4a", 0),
    LFASR_TELEPHONY_RECORDED_AUDIO("电话专用版-已录制音频", "wav,flac,mp3", 2);

    private String name;
    private int value;
    private Map<String, Boolean> supportedAudiosMap = new HashMap();

    LfasrType(String name, String supportedAudios, int value) {
        this.name = name;
        this.value = value;
        String[] supportedExts = supportedAudios.split(",");
        String[] var10 = supportedExts;
        int var9 = supportedExts.length;

        for(int var8 = 0; var8 < var9; ++var8) {
            String ext = var10[var8];
            this.supportedAudiosMap.put(ext, true);
        }

    }

    /**
     * 判断文件是否支持录音
     * @param file
     * @return
     */
    public boolean isSupportedAudios(File file) {
        String fileName = file.getName();

        try {
            int i = fileName.lastIndexOf(".");
            String ext = fileName.substring(i + 1);
            Boolean B = (Boolean)this.supportedAudiosMap.get(ext.toLowerCase());
            return B != null ? B : false;
        } catch (Exception var6) {
            var6.printStackTrace();
            return false;
        }
    }
}
